package CAD;

import java.awt.Component;
import java.util.ArrayList;
import java.util.Vector;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;

import features.Feature;

public class BlockTree  {
	
	
	private JTree tree=null;
	
	 public BlockTree() {
	   super();
	  	DefaultMutableTreeNode top =
		       new DefaultMutableTreeNode("Block:                                       ");
		createNodes(top,MainFrame.features);
	  	tree=new JTree(top);
	    tree.setEditable(true);
	   
	   
	
	    
	}
	 public void refreshTree(){
			DefaultMutableTreeNode top =
			       new DefaultMutableTreeNode("Block:                                       ");
			createNodes(top,MainFrame.features);
		  	tree=new JTree(top);
		    tree.setEditable(true);		   
		   
	 }
	 private void createNodes(DefaultMutableTreeNode top, ArrayList<Feature> features) {
		   DefaultMutableTreeNode blockNode;

		   blockNode = new DefaultMutableTreeNode("Block:");
		    top.add(blockNode);
		   blockNode.add(new DefaultMutableTreeNode(
		    				"Width:"+MainFrame.block.width+"mm")
		    				);
		   blockNode.add(new DefaultMutableTreeNode(
   				"Height:"+MainFrame.block.height+"mm")
   				);
		   blockNode.add(new DefaultMutableTreeNode(
   				"Length:"+MainFrame.block.length+"mm")
   				);
		   blockNode.add(new DefaultMutableTreeNode(
	   				"Tolerance:+/-"+MainFrame.block.tolerance+"mm")
	   				);
		    		
		}

	public Component getTree() {
		// TODO Auto-generated method stub
		return tree;
	}


	
	
	
}
